package com.test.mybatis.generator;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class MapperGenerator {
    private static String daoPath = System.getProperty("user.dir").indexOf("/") == -1 ?
            System.getProperty("user.dir").replace("\\", "/") : System.getProperty("user.dir");

    public static void main(String[] args) {

        String filePath = daoPath + "/fkdx-dao/src/test/java/com/test/mybatis/generator/file/mapper";


        FastAutoGenerator.create("jdbc:mysql://47.95.220.176:3306/fkdx?serverTimezone=GMT%2B8&useSSL=true", "root", "gdhg0Nsrc6Y$hkqi")
                .globalConfig(builder -> {
                    builder.author("wangtengfei") // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 释放执行就会覆盖已生成文件
                            //鼠标右击蓝色java目录，选择Copy Path... 选择 Absolute Path 即可复制路径，粘贴到下面即可
                            .outputDir(filePath); // 指定输出目录


                })
                .packageConfig(builder -> {
                    builder.parent("com.fkdx.dao") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, filePath)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    // 设置需要生成的表名
                    builder.addInclude("t_address");



                    // 设置过滤表前缀
                    //builder.addTablePrefix("t_");
                })
                .execute();
    }
}
